package qr.core;

import java.util.ArrayList;

import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;

@Root
public class Player {
	
	private long id;
	
	@Attribute
	private String name;

	@ElementList
	private ArrayList<Location> FoundLocations;
	
	/**
	 * Empty Constructor
	 */
	public Player() { 
		id = 0; 
		name = ""; 
		FoundLocations = new ArrayList<Location>();
	}
	
	/**
	 * Player Object Constructor
	 * @param UID - Unique Identifer of Player 
	 */
	public Player(String name) { 
		
		this.name = name;
		FoundLocations = new ArrayList<Location>();
	}
	
	/**
	 * Method to execute when player scans QRCode and checks-in to a location
	 * @param QRid - QR code string
	 */
	public void foundLocation(Location QRid) { 
		
		FoundLocations.add(QRid);
	}
	
	/** 
	 * Method to generate and returns stats of player.
	 * Stats of player is the total number of locations found?
	 */
	public ArrayList<Location> getFoundLocation() { 
		
		return FoundLocations;
	}
	
	/** 
	 * Method to get player UID 
	 * @return - returns the string of the unique of the player.
	 */
	public long getId() { 
		
		return id;
	}
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPlayerName() { 
		return name;
	}
	
	public String toString(){
		return getFoundLocation().size() + " - " + getName();
	}
}